import request  from "@/utils/request";
import qs from 'qs'
// 获取编辑菜单页面信息
export const getEditMenuInfo = (id = -1) => {
    return request({
        method: 'GET',
        // url: '/boss/menu/getEditMenuInfo?id=${id}'
        url: '/boss/menu/getEditMenuInfo',
        params: {
            id
        }
    })
}

// 传值为json格式不需要处理
export const createOrderUpdateMenu = data => {
    return request({
        method: 'POST',
        url: '/boss/menu/saveOrUpdate',
        data
    })
}

// 获取全部的目录信息。
export const getAllMenu = () => {
   return request({
    method: 'GET',
    url: '/boss/menu/getAll',
   })
}

// 使用模板方式注意不是' 而是 `
export const deleteMenu = id =>{
    return request({
        method: 'DELETE',
        url: `/boss/menu/${id}`
    }) 
}


// 获取所有菜单并按层级展示
export const getMenuNodeList = () => {
    return request({
      method: 'GET',
      url: '/boss/menu/getMenuNodeList'
    })
  }
  
  // 给角色分配菜单
  export const allocateRoleMenus = data => {
    return request({
      method: 'POST',
      url: '/boss/menu/allocateRoleMenus',
      data
    })
  }
  
  // 获取当前角色拥有的菜单列表接口
  export const getRoleMenus = roleId => {
    return request({
      method: 'GET',
      url: '/boss/menu/getRoleMenus',
      params: {
        roleId
      }
    })
  }
  